<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>老师选择班级</title>
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link href="../../css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/api.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style>
			body {
				background-color: #f3f5f7;
			}
			.mui-table-view-cell.mui-collapse .mui-collapse-content {
				padding: 0
			}
			.line_heigh_left10 {
			
				padding-left: 10px;
			}
			
			.selected_width20_but {
				width: 20px;
			}
		
			
		
			.bgwhite {
				background-color: #FFFFFF
			}
		</style>
	</head>
	<body>
		<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;"></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;">
			<a class="base_left_item"  style="line-height: 44px;margin-left: 10px"onclick="onBackClick()"> 取消</a>
			<span id='nav_title'>选择班级</span>
			<a class="base_right_item "   id="bewrite" onclick="submit()">完成</a>
		</div>
		<div style="margin-top: 66px;">
			<ul class="mui-table-view " id="checkboxes">
				<li class="mui-table-view-cell mui-checkbox mui-media"   id="level_1"value='level_2'>
				
						<samp class="base_dark_grey base_title_font">物流一般</samp>
						<img src="../../image/icon_down_arrow.png" class="selected_width20_but " />
				
					<input dataindex="" name="checkbox2" value="Item 1" type="checkbox">
				</li>
				<li class="mui-table-view-cell mui-checkbox mui-media" id="level_2">
					<div class=" line_heigh_left10 base_grey base_content_font">
						仓储物流二班
					</div>
					<input dataindex="" name="checkbox2" value="Item 1" type="checkbox">
				</li>
			</ul>
		</div>
	</body>
	<script src="../../script/mui.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		apiready = function() {
			addSlideToggleClick();
			setupCheckBoxes();
			prepareData() ;
		};
		function addSlideToggleClick() {
			//点击放显示
			$('#level_1').click(function(event) {
				var chapterClass = "#" + $(this).attr('value');
				$(chapterClass).slideToggle(0);
			});
		}
			function setupCheckBoxes(){
		$("#checkdeAll").prop("checked",false);
		$("#studentNum").text('0');
		//单选
		$("#checkboxes .mui-table-view-cell").unbind('click');
		$("#checkboxes .mui-table-view-cell").click(function(){
			var len = $("#checkboxes input:checkbox:checked").length;//选中个数
			if(len<$("#checkboxes input[type=checkbox]").length){
				$("#checkdeAll").prop("checked",false);
			}
			$("#studentNum").text(len)// 显示选中个数
		});
	}
	function prepareData() {

		//全选
		$("#checkdeAll").click(function(){
			if(this.checked){
				$("#checkboxes input[type=checkbox]").prop("checked",true);
			}else {	
				$("#checkboxes input[type=checkbox]").prop("checked",false);
			}
			var len = $("#checkboxes input:checkbox:checked").length;//选中的个数 
			$("#studentNum").text(len)// 显示选中个数
		})
		//提交绑定事件
		$('#submit').click(function() {
    		var dataindexs = getUserIds();
    		if (dataindexs == null || dataindexs == '' || dataindexs == undefined || dataindexs.constructor != Array  || dataindexs.length == 0) {
    			api.toast({
    			    msg: '请选择学生后再提交'
    			});
    			return;
    		}
//  		var selectedStuIds = new Array();
//  		var selectedStuDatas = new Array();
//  		for (var i = 0; i < dataindexs.length; i++) {
//  			var index = parseInt(dataindexs[i]);
//  			var studentData = currentStudents[index];
//  			var stuId = parseInt(studentData.uid);
//  			var stuName = studentData.rename1;
//  			selectedStuIds.push(stuId);
//  			selectedStuDatas.push({
//  				studentid: stuId,
//  				studentname: stuName
//  			});
//  		}
    		
//  			api.sendEvent({
//  			    name: 'selectStudentNotifi',
//  			    extra: {
//  			        stuArr : selectedStuDatas
//  			    }
//  			});
    			api.closeWin();
    		
   		});
	}
	function getUserIds(){
		var $value = [];
		$('#checkboxes').find('input').each(function(i){
	        if(this.checked==true){
	            $value.push($(this).attr('dataindex'));
	        }
	    });
		return $value;
	}
	</script>
</html>